import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shenfuhui/config/config.dart';

import '../routers/routers.dart';
import '../utils/user_utils.dart';
import '../views/dialog_manager.dart';

///
/// 账户安全
///
class MineAccountSafety extends StatefulWidget {
  const MineAccountSafety({Key? key}) : super(key: key);

  @override
  State<MineAccountSafety> createState() => _MineAccountSafetyState();
}

class _MineAccountSafetyState extends State<MineAccountSafety> {
  ///
  /// 返回普通的列表item
  ///
  Widget getListItem(
      IconData icon, String title, String subTitle, Function() onTap) {
    return ListTile(
      onTap: onTap,
      leading: Icon(icon, size: 43.w),
      title: Text(title, style: TextStyle(fontSize: 25.w)),
      horizontalTitleGap: 0,
      dense: true,
      iconColor: Config.colorText1,
      textColor: Config.colorText1,
      trailing: SizedBox(
        width: 300.w,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            Text(subTitle,
                style: TextStyle(fontSize: 23.w, color: Config.colorText3)),
            Padding(padding: EdgeInsets.all(10.w)),
            Icon(Icons.arrow_forward_ios, size: 20.w),
          ],
        ),
      ),
      contentPadding: EdgeInsets.symmetric(vertical: 9.w, horizontal: 0),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Config.colorBg2,
        appBar: AppBar(
          title: const Text('账户安全'),
          centerTitle: true,
        ),
        body: Container(
          height: double.infinity,
          width: double.infinity,
          child: Column(
            children: [
              Container(
                //中间列表区
                width: double.infinity,
                height: 365.w,
                padding: EdgeInsets.symmetric(vertical: 0, horizontal: 0.w),
                margin: EdgeInsets.symmetric(vertical: 30.w, horizontal: 30.w),
                decoration: BoxDecoration(
                  color: (Config.colorWhite),
                  borderRadius: BorderRadius.circular(12.w),
                ),
                child: ListView(
                  physics: const NeverScrollableScrollPhysics(),
                  padding:
                      EdgeInsets.symmetric(vertical: 6.w, horizontal: 30.w),
                  children: [
                    getListItem(Icons.password_outlined, "修改登录密码", "", () {
                      Routes.navigateTo(context, Routes.mineChangePassword,
                          params: {'pageTitle': '修改登录密码'});
                    }),
                    Divider(
                      height: 2.w,
                      color: Config.colorDivider,
                    ),
                    getListItem(Icons.admin_panel_settings_sharp, "修改支付密码", "",
                        () {
                      Routes.navigateTo(context, Routes.mineChangePassword,
                          params: {'pageTitle': '修改支付密码'});
                    }),
                    Divider(
                      height: 2.w,
                      color: Config.colorDivider,
                    ),
                    getListItem(Icons.phone_android, "绑定手机", "", () {
                      Routes.navigateTo(context, Routes.mineChangeMobile);
                    }),
                  ],
                ),
              ),
            ],
          ),
        ));
  }
}
